<template>
  <div class="page">
    <h2>单点登录演示前端页面</h2>
    <li class="fa fa-home fa-lg"></li>
    <el-button type="primary" @click="testAxios()">测试Axios调用</el-button>
    <el-button type="primary" @click="getUser()">获取用户信息</el-button>
    <el-button type="primary" @click="getMenu()">获取菜单信息</el-button>
    <h3>{{$t('common.doc')}}</h3>
    <el-button type="success" @click="changeLanguage('zh_cn')">简体中文</el-button>
    <el-button type="success" @click="changeLanguage('en_us')">English</el-button>

    <h3>{{$t('common.skip')}}</h3>
    <a href="http://app.mongo.com">
      <el-button type="warning">{{$t('common.system1')}}</el-button>
    </a>
    <br />
    <a href="http://user.mongo.com">
      <el-button type="warning" style="margin-top: 10px;">{{$t('common.system2')}}</el-button>
    </a>
  </div>
</template>

<script>
// @ is an alias to /src
import axios from "axios";
import mock from "@/mock/index.js";

export default {
  name: "Home",
  methods: {
    // 语言切换
    changeLanguage(lang) {
      lang === "" ? "zh_cn" : lang;
      this.$i18n.locale = lang;
      this.langVisible = false;
    },
    testAxios() {
      axios.get("http://localhost:8080").then(res => {
        alert(res.data);
      });
      // alert("aaaaa")
    },
    getUser() {
      axios.get("http://localhost:8080/user").then(res => {
        alert(JSON.stringify(res.data));
      });
    },
    getMenu() {
      axios.get("http://localhost:8080/menu").then(res => {
        alert(JSON.stringify(res.data));
      });
    }
  }
};
</script>
